package com.shen.langchain4j.controller;

import dev.langchain4j.model.chat.ChatModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 大模型控制层接口
 */
@Slf4j
@RestController
@RequestMapping(value = "/langchain4j")
public class LangChain4JFirstController {
    @Autowired
    private ChatModel chatModel;

    @GetMapping(value = "/hello")
    public String helloModel(@RequestParam(value = "question", defaultValue = "你是谁") String question) {
        String result = chatModel.chat(question);
        log.info("调用大模型结果为: {}", result);
        return result;
    }


}
